package com.academico.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connect {
	
	private static final String URL = "jdbc:mysql://localhost/academico";
	private static final String USER_NAME = "root";
	private static final String PASSWORD = "";
	
	private static Connection conn;
	
	public static Connection getInstance(){
		if(conn == null){
			try {
				Class.forName("com.mysql.jdbc.Driver").newInstance();
				conn = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
			} catch (Exception e) {
				e.printStackTrace();
			} 
		}
		return conn;
	}
	
	public static void close(){
		if(conn != null){
			try {
				conn.close();
				conn = null;
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
}